package com.tianhui.consignortwofei.mvp.ui.activity.hetong.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.fgs.common.pictureSelector.GlideEngine;
import com.tianhui.consignortwofei.R;
import com.tianhui.consignortwofei.constant.Config;
import com.tianhui.consignortwofei.mvp.model.hetong.LiuChengListBean;

import org.yczbj.ycrefreshviewlib.adapter.RecyclerArrayAdapter;
import org.yczbj.ycrefreshviewlib.holder.BaseViewHolder;

/**
 * @author fgs
 * @date 2020/4/1
 * @description
 **/
public class LiuChengShowListAdapter extends RecyclerArrayAdapter<LiuChengListBean> {


    private Context mContext ;
//    private OrderOperateView.OnOrderOperateClickListener onOrderOperateListener;

    public LiuChengShowListAdapter(Context context) {//, IOrderStatus iOrderStatus
        super(context);
        mContext=context;
//        this.iOrderStatus = iOrderStatus;
    }

//    public void setOnOrderOperateListener(OrderOperateView.OnOrderOperateClickListener onOrderOperateListener) {
//        this.onOrderOperateListener = onOrderOperateListener;
//    }

    @Override
    public BaseViewHolder OnCreateViewHolder(ViewGroup parent, int viewType) {
        LiuChengShowViewHolder viewHolder = new LiuChengShowViewHolder(parent, R.layout.item_liucheng_show);
        return viewHolder;
//        switch (viewType) {
//            case 0:
//                return new newsSmallImgViewHolder(parent, R.layout.item_news_small);
//            case 1:
//                return new newsThreeViewHolder(parent, R.layout.item_news_three_image);
//
//            case 2:
//                return new newsBigImgViewHolder(parent, R.layout.item_video_big);
//            case 3:
//                return new newsMomentsViewHolder(parent, R.layout.item_moments_text);
//        }
//        return null;


    }





    public class LiuChengShowViewHolder extends BaseViewHolder<LiuChengListBean> {

        private ImageView iv_dui;
        private TextView tv_name;
        private ImageView iv_image;
        private TextView tv_text;
        private TextView tv_time;
        private TextView tv_hint;



        public LiuChengShowViewHolder(ViewGroup parent, int res) {
            super(parent, res);

            iv_dui = (ImageView) getView(R.id.iv_dui);
            tv_name = (TextView) getView(R.id.tv_name);
            iv_image = (ImageView) getView(R.id.iv_image);
            tv_text = (TextView)getView(R.id.tv_text);
            tv_time = (TextView) getView(R.id.tv_time);
            tv_hint = (TextView) getView(R.id.tv_hint);



            addOnClickListener(R.id.iv_image);
//            bigTvTime = (TextView) getView(R.id.big_tv_time);
//            bigTvCommentNum = (TextView) getView(R.id.big_tv_comment_num);
//            bigIvComment = (ImageView) getView(R.id.big_iv_comment);
//            bigTvLikeNum = (TextView) getView(R.id.big_tv_like_num);
//            bigIvLike = (ImageView) getView(R.id.big_iv_like);

        }

        @Override
        public void setData(LiuChengListBean data) {
            super.setData(data);


            if (null==data.getPlanusername()||TextUtils.isEmpty(data.getPlanusername())){
                tv_name.setText(data.getName() );
            }else {
                tv_name.setText(data.getName() + "(" + data.getPlanusername() + ")");
            }

            if ("0".equals(data.getStatus())){
                iv_image.setVisibility(View.GONE);
                tv_hint.setVisibility(View.GONE);
                tv_time.setVisibility(View.GONE);

                tv_text.setVisibility(View.VISIBLE);
                tv_text.setText("审核中...");
                tv_text.setTextColor(mContext.getResources().getColor(R.color.colorPrimary));
            }else if ("1".equals(data.getStatus())||"2".equals(data.getStatus())||
                    "3".equals(data.getStatus())||"4".equals(data.getStatus())||
                    "5".equals(data.getStatus())||"6".equals(data.getStatus())){

                if (null!=data.getImgattachment()&&!TextUtils.isEmpty(data.getImgattachment())) {
                    iv_image.setVisibility(View.VISIBLE);
                    GlideEngine.createGlideEngine().loadImage(mContext, Config.baseImageUrlTwo + data.getImgattachment(), iv_image);
                }else {
                    iv_image.setVisibility(View.GONE);
                }

                if (null==data.getRemark()||TextUtils.isEmpty(data.getRemark())) {
                    tv_text.setVisibility(View.GONE);
                }else {
                    tv_text.setVisibility(View.VISIBLE);
                    tv_text.setTextColor(mContext.getResources().getColor(R.color.black));
                    tv_text.setText("意见："+data.getRemark());
                }

                String name="";
                if (TextUtils.isEmpty(data.getVerifyusername())){
                    name="自动审核";
                }else {
                    name=data.getVerifyusername();
                }

                if ("2".equals(data.getStatus())){
                    tv_time.setText(name+" 拒绝于"+data.getVerifytime());
                }else {
                    tv_time.setText(name+" 提交于"+data.getVerifytime());
                }

//                if (null==data.getVerifytime()||TextUtils.isEmpty(data.getVerifytime())){
//                    iv_dui.setImageDrawable(mContext.getResources().getDrawable(R.drawable.shape_circle_blue));
//                }else {
                    iv_dui.setImageResource(R.mipmap.checkmark_blue);
//                }

            }else {
                iv_image.setVisibility(View.GONE);
                tv_text.setVisibility(View.INVISIBLE);
                tv_hint.setVisibility(View.GONE);
                tv_time.setVisibility(View.GONE);
            }



        }
    }










}
